package com.s3_boot_mp.controller;

import com.s3_boot_mp.mapper.UserMapper;
import com.s3_boot_mp.pojo.SysUser;
import com.s3_boot_mp.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class UserController {
    @Resource
    UserService userService;

    @RequestMapping("/userlist")
    public Object getUserList() {
        return userService.findAllUsers();
    }
    @GetMapping(value = "/user/{id}")
    public SysUser getUserById(@PathVariable("id") Long usrId){
        return userService.getUser(usrId);

    }
    @PostMapping(value = "/user")
    public void addUser(SysUser user){
        userService.addUser(user);
    }
    @PutMapping(value = "/user")
    public void updateUser(SysUser user){
        userService.updateUser(user);
    }
    @DeleteMapping(value = "/user/{id}")
    public void deleteUser(@PathVariable("id") Long usrId){
        userService.delUser(usrId);
    }
}
